<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <style>
    input {
        display: block;
    }
    
    </style>
    <title>Get Elements by Name</title>
</head>
<body>
    <input type="button" value="Click" id="btn">
    <input type="text" name="name1" id="" value="I'm a text input box.">
    <input type="text" name="name2" id="" value="I'm a text input box.">
    <input type="text" name="name3" id="" value="I'm a text input box.">
    <input type="text" name="name1" id="" value="I'm a text input box.">
    <input type="text" name="name2" id="" value="I'm a text input box.">
    <input type="text" name="name3" id="" value="I'm a text input box.">
    <input type="text" name="name1" id="" value="I'm a text input box.">
    <input type="text" name="name2" id="" value="I'm a text input box.">
</body>


<script>
    function my$(id) {
        return document.getElementById(id);

    };

    my$("btn").onclick = function() {
        var inputs = document.getElementsByName("name1");
        for (i=0; i<inputs.length; i++){
            inputs[i].value = "You got me!";
        };
    };


</script>

</html>